/*
 * @Author: Caijw
 * @Date: 2018-11-06 13:01:42
 * @LastEditors: Caijw
 * @LastEditTime: 2018-12-16 21:51:06
 * @Description:  这里是公共api接口
 */
import axios from './api';

//获取用户接口
export let getUsers = () =>{
    return axios.get('/users');
}


//获取用户信息
export let getUserInfo = () =>{
    return axios.get('/api/profile');
}

//签到
export let postSignInfo = () =>{
    return axios.post('/api/sign-in');
}

//改变名字
export let postChangeName = (id,data) =>{
    return axios.patch('/api/user/' + id,data);
}


//获取周边信息
export let getStore = async (page, kw='', code, lat, lng) =>{
    return axios.get(`/api/store?page=${page}&kw=${kw}&code=${code}&latitude=${lat}&longitude=${lng}`);
}

//获取周边详情
export let getStoreDetail = (id) =>{
    return axios.get('/api/store/'+ id);
}


//充值卡 coupon_card_pub_key coupon_card_pri_key
export let postCard = (data) =>{
    return axios.post('/api/couponCard',data);
}


export let getCardList = () =>{
    return axios.get('/api/couponCard');
}


//收藏和浏览的记录 1，收藏 2 浏览
export let getCollection = (page) =>{
    return axios.get(`/api/collectAndViewhistory?type=1&page=${page}`);
}
export let getView = (page) => {
    return axios.get(`/api/collectAndViewhistory?type=2&page=${page}`);
}


//关于页面
export let getAbout = () =>{
    return axios.get('/api/about');
}

//我的余额
export let getMyMoney = () =>{
    return axios.get('/api/withdrawal/create');
}

//绑定卡片
export let bindAliCard = (data) =>{
    return axios.post('/api/user-finance-account', data);
}


//体现
export let getMoney = (data) =>{
    return axios.post('/api/withdrawal', data);
}

//消息
export let getMessage = (page) =>{
    return axios.get(`/api/push-message-log?page=${page}`);
}

//订单
//消息
export let getOrder = (page,order_state) =>{
    return axios.get(`/api/tb-offical-order?page=${page}&order_state=${order_state}`);
}


//新增地址
export let postAddress = (data) =>{
    return axios.post(`/api/user-address`, data);
}

//修改地址
export let pathAddress = (id,data) =>{
    return axios.patch(`/api/user-address/${id}`, data);
}

//地址列表
export let getAddress = () =>{
    return axios.get(`/api/user-address`);
}

//删除地址
export let deleteAddress = (id) =>{
    return axios.delete(`/api/user-address/${id}`);
}


//获取地址明细
export let getAddressDetail = (id) =>{
    return axios.get(`/api/user-address/${id}`);
}


export let getAddressJSON = () =>{
    return axios.get(`/api/district-json`);
}



